package com.liao.intimacy;

import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapper;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.Text;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class RankMapper extends TableMapper<Text, Text> {

    @Override
    protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException {
        //01_15837312345_2017-08-10 14:10:24_13738909097_1_0180

        String rowkey= Bytes.toString(value.getRow());//获得一行电话日志
        String[] values=rowkey.split("_");//分割电话日志
//        String flag=values[4];//是否建立连接
//        if ("0".equals(flag)) return;//如果没有建立通话直接返回结束
        String call1 = values[1];//打电话人1
        String call2 = values[3];//打电话人2
        String duration = values[5];//通话时长（秒）
        context.write(new Text(call1+"_"+call2),new Text(duration));//写出
        //133_144   158
    }
}
